<template>

	<view style="height: 100%; width: 100%;">
		<myMap   :points="points"></myMap>
	</view>
</template>


<script>
	import myMap from "./map.vue"
	export default {
		components: {
			myMap
		},
		data() {
			return {
				points: []
			};
		},
		methods: {
			onShow() {
				console.log("onShow")
			},
			onLoad() {
				console.log("onLoad");
				this.startGetLocation()
			},
			startGetLocation: function() {
				let that = this;
				uni.startLocationUpdate({
					success: res => {
						uni.onLocationChange(function(res2) {
							uni.showToast({
								title: '经度：' + res2.longitude + '纬度：' + res2.latitude +
									"速度 (m/s)" + res2.speed + "精确:" + res2.accuracy,
								icon: 'none',
							});
							let newPoint = {
								latitude: res2.latitude,
								longitude: res2.longitude,
								speed: res2.speed
							};
							console.log(newPoint)
							that.points.push(newPoint);
							// 动态更新地图轨迹
							// that.setDateByPoints(that.points);

						});
					},
					fail: err => {
						uni.showToast({
							title: err,
							icon: 'none',
						});
					},
					complete: msg => console.log('调用开启小程序接收位置消息 API 完成')
				});
			},
		}
	}
</script>